<template lang="jade">
h-loader-full(url='loader',:setdata='false')
  h-data-lister(data='list')
  .box
    //查询
    m-title(icon='add',name='培训学校列表')
      select(v-model='p.type',placeholder='请选择类别')
        option(value='', selected) 请选择类别
        option(v-for='(n,i) in type', :value='i') {{n}}
      select(v-model='p.category',placeholder='请选择培训学校/机构')
        option(value='', selected) 请选择学校/机构
        option(v-for='(n,i) in category', :value='i') {{n}}
      select(v-model='p.show',placeholder='请选择显示位置')
        option(value='', selected) 请选择显示位置
        option(v-for='(n,i) in show', :value='i') {{n}}
      input(type = 'text',v-model='p.name',placeholder='请填写学校名称',style='width:95px;')
      button(@click='goFilter(p)') 过滤
    //人员信息
    table.list
      ml-header(data='显示位置,学校/机构,所属类别,名称,地址,外层显示图片,排序,操作')
      tr(v-for='(n,i) in list')
        td {{show[n.show]}}
        td {{category[n.category]}}
        td {{type[n.type]}}
        td {{n.name}}
        td {{n.address}}
        td
          <img :src="'http://image.cdn.hesq.com.cn/xiongan/logo/'+n.img" style='width:80px;'>
        td: input(type='text',v-model='n.sort')
        td
          a(href='javascript:void(0)',class='update',:data-index='i') 更新
          a(:href="'./school_edit.html?sid=' + n.id") 编辑
          a(href='javascript:void(0)', @click="delete_school(n)") 删除
    .command
      button(id='update-all') 全部更新
      .page
        button(v-show='page>1', @click="pagego('last')") 上一页
        button {{page}}
        button(@click="pagego('next')") 下一页
</template>
----------------------------------------------------------------------------------------
<script>
import { MessageBox } from 'mint-ui'
export default {
	data () {
		return {
			loader:{
        list:'cultivate/school/list'
      },
      url:{
				update:'cultivate/school/sort',
			},
      list:[],
      p:{
        category:'',
        type:'',
        name:'',
        show:'',
      },
      category:['学校','机构'],
      type:['精品培训','职称考试','合作培训'],
      show:['两端显示','用户端','企业端'],
      page:1,
		}
	},
  mounted () {
  },
	methods: {
		loadAfter(data){
      this.list=data.list[0]
		},
    updataAfter (res) {
			this.$msg.success()
			setTimeout("window.location.reload()",1000)
		},
    //过滤
    goFilter (p) {
			this.$ajax.get('cultivate/school/list?category='+ this.p.category + '&type=' + this.p.type + '&name=' + this.p.name + '&show=' + this.p.show, (res) => {
				this.list = res.data[0]
        this.page = 1
			}, (res) => {
				this.error(res.message)
			})
		},
    // 分页
    pagego (type) {
      this.page = type == 'last' ? this.page - 1 : this.page + 1
      this.$ajax.get('cultivate/school/list?category='+ this.p.category + '&type=' + this.p.type + '&name=' + this.p.name + '&show=' + this.p.show + '&page=' + this.page, (res) => {
        this.list = res.data[0]
      }, (res) => {
        this.error(res.message)
      })
    },
    //删除
    delete_school(n){
      if(confirm("确定要删除,删除后相关数据将无法恢复")){
        this.$ajax.delete("cultivate/delete/school?id="+n.id, (res)=>{
          this.$msg.success(res.message);
          window.location.href = window.location.href;
        }, (res)=>{
          this.$msg.error(res.message);
        })

      }
    },
	}
}
</script>
----------------------------------------------------------------------------------------
<style lang="less" scoped>
@import "../../../plugin/style/mixin";
.page{ float:right; }
  .page a{background: #4db3ff; color: #fff; padding:3px 10px; border-radius:4px; cursor:pointer;}
  .page b{margin:0 10px;}
</style>